@echo off

echo Enter Server (localhost\SQLExpress)
set /p server=

echo Enter DB (Database Name)
set /p db=

echo Enter Version (Leave if you want latest)
set /p ver=

echo Enter Task (migrate:up or migrate:down)
set /p task=

IF "%server%" == "" (
       set server=localhost\SQLExpress
)
IF "%db%" == "" (
       set db=Media
)
IF "%ver%" == "" (
       set ver=0
)
IF "%task%" == "" (
       set task=migrate:up
)

set conn=Data Source=%server%;Initial Catalog=%db%;Trusted_Connection=True;

echo Confirm [y/n] Connection "%conn%" - Version %ver% - Task %task%
set /p confirm=

IF "%confirm%" == "y" (
    sqlcmd -E -S %server% -Q "IF db_id('%db%') IS NULL BEGIN CREATE DATABASE %db% END" 
    @migrate40.exe -a Media.Migrator.dll -db sqlserver -c "%conn%" -version %ver% -t %task%
) ELSE (
    echo cancelled
)

pause